function getConfirmCode() {
    var ComfirmCodeValue = "0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z";
    var ComfirmCodeArray = ComfirmCodeValue.split(',');
    var ComfirmCode = '';
    for (var i = 0; i < 4; i++) {
        ComfirmCode += ComfirmCodeArray[Math.floor(Math.random() * 36)];
    }
    $('.confirmCode').text(ComfirmCode);
}
getConfirmCode();
$('.confirmCode').click(function () {
    getConfirmCode();
});
$('form').submit(function (e) {
    e.preventDefault();
    var psw = $(':password').map(function () {
        return $(this).val();
    })
    if (psw[0] == psw[1]) {
        if ($('#confirmCode').val().toUpperCase() == $('.confirmCode').text()) {
            $.post(this.action, $(this).serialize(), (data) => {
                alert(data.message);
                if (data.code == 'success') {
                    location.href = '/login.html';
                }
            })
        } else {
            alert('验证码输入不正确');
            getConfirmCode();
        }
    } else {
        alert('两次密码输入不一致');
    }
})